package com.ruoyi.web.controller.production.graftinglabel;

import java.util.List;

import com.ruoyi.common.annotation.PropertyInject;
import com.ruoyi.common.enums.InjectType;
import com.ruoyi.production.service.graftinglabel.IGraftinglabelAmountService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.production.domain.graftinglabel.GraftinglabelPurchase;
import com.ruoyi.production.service.graftinglabel.IGraftinglabelPurchaseService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 嫁接签购买信息Controller
 *
 * @author ruoyi
 * @date 2021-07-12
 */
@RestController
@RequestMapping("/production/graftinglabelPurchase")
@Api(value = "嫁接签购买",tags = "嫁接签购买相关API")
public class GraftinglabelPurchaseController extends BaseController
{
    @Autowired
    private IGraftinglabelPurchaseService graftinglabelPurchaseService;
    @Autowired
    private IGraftinglabelAmountService graftinglabelAmountService;

    /**
     * 查询嫁接签购买信息列表
     */
    @PreAuthorize("@ss.hasPermi('production:graftinglabelPurchase:list')")
    @GetMapping("/list")
    @ApiImplicitParam(name = "graftinglabelPurchase",value ="嫁接签购买实体类",paramType = "body",dataType = "GraftinglabelPurchase")
    public TableDataInfo list(GraftinglabelPurchase graftinglabelPurchase)
    {
        startPage();
        List<GraftinglabelPurchase> list = graftinglabelPurchaseService.selectGraftinglabelPurchaseList(graftinglabelPurchase);
        return getDataTable(list);
    }

    /**
     * 导出嫁接签购买信息列表
     */
    @PreAuthorize("@ss.hasPermi('production:graftinglabelPurchase:export')")
    @Log(title = "嫁接签购买信息", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    @ApiImplicitParam(name = "graftinglabelPurchase",value ="嫁接签购买实体类",paramType = "body",dataType = "GraftinglabelPurchase")
    public AjaxResult export(GraftinglabelPurchase graftinglabelPurchase)
    {
        List<GraftinglabelPurchase> list = graftinglabelPurchaseService.selectGraftinglabelPurchaseList(graftinglabelPurchase);
        ExcelUtil<GraftinglabelPurchase> util = new ExcelUtil<GraftinglabelPurchase>(GraftinglabelPurchase.class);
        return util.exportExcel(list, "嫁接签购买信息数据");
    }

    /**
     * 获取嫁接签购买信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('production:graftinglabelPurchase:query')")
    @GetMapping(value = "/{graftinglabelPurchaseId}")
    @PropertyInject(type = InjectType.Insert)
    @ApiOperation("获取嫁接签购买表单个信息")
    @ApiImplicitParam(name = "graftinglabelPurchaseId",value ="嫁接签购买实体主键",paramType = "path",dataType = "Long")
    public AjaxResult getInfo(@PathVariable("graftinglabelPurchaseId") Long graftinglabelPurchaseId)
    {
        return AjaxResult.success(graftinglabelPurchaseService.selectGraftinglabelPurchaseById(graftinglabelPurchaseId));
    }

    /**
     * 新增嫁接签购买信息
     */
    @PreAuthorize("@ss.hasPermi('production:graftinglabelPurchase:add')")
    @Log(title = "嫁接签购买信息", businessType = BusinessType.INSERT)
    @PostMapping
    @PropertyInject(type = InjectType.Insert)
    @ApiOperation("新增嫁接签购买表信息")
    @ApiImplicitParam(name = "graftinglabelPurchase",value = "嫁接签购买实体类",paramType = "body", dataType = "GraftinglabelPurchase")
    public AjaxResult add(@RequestBody GraftinglabelPurchase graftinglabelPurchase)
    {
        return toAjax(graftinglabelPurchaseService.insertPurchaseUpdateAmount(graftinglabelPurchase));

    }


    /**
     * 修改嫁接签购买信息
     */
    @PreAuthorize("@ss.hasPermi('production:graftinglabelPurchase:edit')")
    @Log(title = "嫁接签购买信息", businessType = BusinessType.UPDATE)
    @PutMapping
    @PropertyInject(type = InjectType.Update)
    @ApiOperation("修改嫁接签购买表信息")
    @ApiImplicitParam(name = "graftinglabelPurchase",value = "嫁接签购买实体类",paramType = "body", dataType = "GraftinglabelPurchase")
    public AjaxResult edit(@RequestBody GraftinglabelPurchase graftinglabelPurchase)
    {
        return toAjax(graftinglabelPurchaseService.updateGraftinglabelPurchase(graftinglabelPurchase));
    }

    /**
     * 删除嫁接签购买信息
     */
    @PreAuthorize("@ss.hasPermi('production:graftinglabelPurchase:remove')")
    @Log(title = "嫁接签购买信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{graftinglabelPurchaseIds}")
    @ApiOperation("删除嫁接签购买表信息")
    @ApiImplicitParam(name = "graftinglabelPurchaseIds",value = "嫁接签购买实体类主键数组",paramType = "path", dataType = "Long")
    public AjaxResult remove(@PathVariable Long[] graftinglabelPurchaseIds)
    {
        return toAjax(graftinglabelPurchaseService.deleteGraftinglabelPurchaseByIds(graftinglabelPurchaseIds));
    }
}
